<template>
	<view>
		<ss-preview :fileUrl="fileUrl" :fileType="fileType" :imageList="imageList"></ss-preview>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileUrl: '',
				fileType: '',
				imageList: [],
			}
		},
		onLoad(option) {
			this.imageList = []
			let reg = /(\.gif|\.jpeg|\.png|\.jpg|\.bmp)/i;
            let suffix =option.title.substring(option.title.lastIndexOf("."));
			if (reg.test(suffix)) {
				this.fileType = '1'
			}else if(suffix === '.pdf'){
				this.fileType = '2'
			}else{
				this.$modal.showToast('暂不支持该文件类型预览~')
			}
			this.fileUrl = option.src;
			if (this.fileType === '1') {
				this.imageList.push(option.src)
			}
			if (option.title) {
				uni.setNavigationBarTitle({
					title: option.title
				})
			}
		}
	}
</script>

<style>
</style>